<%@ page pageEncoding="UTF-8"%>
<%@ include file="/common/validate.jsp"%>
<%@ include file="/common/operatehistory.jsp"%>
<%@ include file="/common/user.jsp"%>
<%@ include file="/common/comment.jsp"%>
<%!
// 新闻详情
String article(Input input) {
	Map map = new HashMap();
	Integer hospital = input.getInt("hospital", -1); // 医院id
	Integer newsId = input.getInt("news_id", -1); // 新闻id
	Integer branch = input.getInt("branch", -1);
	Integer uuid = input.getInt("uid", -1);
	Where where = new Where();
	if (branch != -1) {
		where.and("branch=", branch);
	}
	List article = QBuilder.db("basedb").select("new map(id as id, title as title, time as time, author as author, content as content, img as img, jsonString as json)").from("News").where(where.and("hospital=", hospital).and("newsId =", newsId ).and("status = ", STATUS_ENABLE)).query().getResultObj();
	Message msg = new Message(0);
	if (article.size() == 0) {
		msg = new Message(30001, "新闻不存在");
		return msg.toJson();
	}
	Map<String, Object> news = (Map<String, Object>)article.get(0);
	completeOperateCount(news, NEWS_CATEGORY,  hospital,  uuid);
	news.put("content", filterIllegalCharacter(Tools.getDesc(news.get("content"))));
	news.put("img", JSONUtil.fromJson(isEmpty(news.get("img") + "")?"[]":(news.get("img") + ""), new TypeReference<List<Map>>(){}));
	news.put("json",(Map)JSON.parse(news.get("json").toString().replaceAll("\r","").replaceAll("\n","")));
	map.put("news", news);
	OperateHistory oh = new OperateHistory();
	oh.setHospital(hospital);
	oh.setCategory(NEWS_CATEGORY);
	oh.setUid(uuid+"");
	oh.setOid(news.get("id")+"");
	oh.setOperate(SEE);
	operate(oh, false);
	map.put("comment", query(null, Tools.getInt(news.get("id")+"", 0), hospital, NEWS_COMMENT));
	msg.put("data", map);
	return msg.toJson();
}
%>
<%
	Tools.encryptPrint(out, article(input));
%>
